package es.uma.scgt.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import es.uma.scgt.dao.TestDao;
import es.uma.scgt.modelo.Test;

@Repository
public class TestDaoImpl implements TestDao {
	@Autowired
	private SessionFactory session;

	public void add(Test student) {
		session.getCurrentSession().save(student);
	}

	public void edit(Test student) {
		session.getCurrentSession().update(student);
	}

	public void delete(int studentId) {		
		session.getCurrentSession().delete(getStudent(studentId));
	}

	public Test getStudent(int studentId) {
		return (Test)session.getCurrentSession().get(Test.class, studentId);
	}

	public List getAllStudent() {
		return session.getCurrentSession().createQuery("from Test").list();
	}
	
	

}
